package com.eddie.tree;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author Eddie
 * @date 2022/08/09 10:46
 **/
public class Test {
    public static void main(String[] args) {
        //arrayList维护了Object[]数组，在空参构造器种给了一个空数组{}
        ArrayList<Object> objects = new ArrayList<>(0);
        objects.add(new Object());

        /**\
         * 该方法使用某种策略进行自动扩容
         * private Object[] grow(int minCapacity) {
         *         int oldCapacity = elementData.length;
         *         if (oldCapacity > 0 || elementData != DEFAULTCAPACITY_EMPTY_ELEMENTDATA) {
         *         int newCapacity = ArraysSupport.newLength(oldCapacity,
         *         minCapacity - oldCapacity,);
         *         return elementData = Arrays.copyOf(elementData, newCapacity);
         *         } else {
         *         return elementData = new Object[Math.max(DEFAULT_CAPACITY, minCapacity)];
         *         }
         *         }
         */
        byte b = 10;
        b = 100;
        System.out.println(b);
        double d1= 1.12;
        /*
        参数构造器在初始化时设置好elementData的容量为initialCapacity,
        如果输入0的话将elementData设置为空数组，小于0则直接报错
        public ArrayList(int initialCapacity) {
        if (initialCapacity > 0) {
            this.elementData = new Object[initialCapacity];
        } else if (initialCapacity == 0) {
            this.elementData = EMPTY_ELEMENTDATA;
        } else {
            throw new IllegalArgumentException("Illegal Capacity: "+
                                               initialCapacity);
        }
    }
         */
    }

}

